<?php
/**
 * $Id: default.php 11917 2009-05-29 19:37:05Z ian $
 */
defined( '_JEXEC' ) or die( 'Restricted access' );

$cparams = JComponentHelper::getParams ('com_media');
$template_dir = 'templates/tpl_automobil/';
$db = JFactory::getDBO();
$db->setQuery("SELECT introtext FROM #__content WHERE id = 20");
$text = $db->loadResult();
?>


<div style="display: none;position: fixed; top: 0;left: 0;width: 100%;height: 100%;background-color: #000000;z-index:10000;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);" id="backoverlay"></div>
<script src="templates/tpl_automobil/js/jquery.validate.js" type="text/javascript"></script>
 
<form action="<?php echo JRoute::_( 'index.php' );?>" method="post" name="emailForm" id="emailForm">
<div class="w739 float_right">
	<div class="">
     
         <div class="tt p5t"><?php echo $this->params->get( 'page_title' ); ?></div>
    </div>
    <div class="p5t">
    	<div class="p10l p15t">
        	<div class="w226 bg_right float_left p30b">
            	<p class=" p15b font16"><?php echo $this->contact->address; ?></p>
            	<table cellspacing="0" cellpadding="0" border="0" width="100%">
              		<tbody><tr>
                		<td width="42%" height="20">Telefon:</td>
                		<td width="58%"><?php echo $this->contact->telephone; ?></td>
              		</tr>
              		<tr>
                		<td height="20">Fax: </td>
                	
                        	<td><?php echo $this->contact->fax; ?></td>
              		</tr>
              		<tr>
                		<td height="20">Mail: </td>
                		<td><a href="mailto:<?php echo $this->contact->email_to; ?>"><?php echo $this->contact->email_to; ?></a></td>
              		</tr>
              		</tbody>
            	</table>
            </div>
            <div class=" p15l form_contact p15b">
                <input type="text" value="Navn" class="txt_contact w390" name="name" id="navn" />
                <input type="text" value="Email" class="txt_contact w390" name="email" id="email" />
                <textarea rows="" cols="" name="text" id="text">Besked...</textarea><br />
             
               <a onclick="check_contact();" href="javascript:void(0);"><img src="templates/tpl_automobil/images/bt_send.jpg"/></a>    
             <input type="submit" value="send_contact" id="send_contact" name="send_contact" style="display:none;" />
               
               <input type="image" src="templates/tpl_automobil/images/bt_nulstil.jpg" name="" id="reset" />   
                
           <!--     <input type="image" src="<?php echo $template_dir;?>images/bt_send.jpg" name="" id="submit" onclick="check_contact();" /> -->
                
            </div>
            <p class="cb"></p>
        	<div class="boder_t_d">
        		<?php echo $text;?>
			</div>
        </div>
	</div>
</div>
    <input type="hidden" name="option" value="com_contact" />
	<input type="hidden" name="view" value="contact" />
	<input type="hidden" name="id" value="<?php echo $this->contact->id; ?>" />
	<input type="hidden" name="task" value="submit" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>


<script>
var value = "";
$('.txt_contact,#text').focus(function() {
     value=$(this).val();
     $(this).attr("value","");
    });
$('.txt_contact,#text').blur(function() {
     if($(this).val()=="") {
      $(this).val(value);
     }
    });
    $('#reset').click(function(){
     $("#navn").attr("value","Navn");
     $("#email").attr("value","Email");
   //  $("#contact_telephone").attr("value","Tlf.:nr");
     $("#text").attr("value","Besked...");
     return false;
    });
</script>
<script type="text/javascript">
	$(document).ready(function(){
	
    check_contact=function(){
        
        if(($('#navn').attr("value") == "" )|| ($('#navn').attr("value") == "Navn")){
            $('#alert').html('Udfyld venligst navn ');
            $('#backoverlay').show();
            $('#show_popup').show();
            $('#f_focus').html('email');
            return false;	
        }
        
        if(($('#email').attr("value") == "" )|| ($('#email').attr("value") == "Email")){
            $('#alert').html('Udfyld venligst email');
            $('#backoverlay').show();
            $('#show_popup').show();
            $('#f_focus').html('email');
            return false;	
        }
        else{
            if(!isEmail($('#email').val())){
                $('#alert').html('Venligst e-mail er gyldig');
                $('#backoverlay').show();
                $('#show_popup').show();
                $('#s_focus').html('email');
                return false; 
            }
        }
		
      if(($('#text').attr("value") == "" )|| ($('#text').attr("value") == "Besked...")){
			$('#alert').html('Udfyld venligst besked');
            $('#backoverlay').show();
			$('#show_popup').show();
			$('#f_focus').html('passwd');
			return false;	
		}
            
        //$('#com_form_login').submit();
        $('#send_contact').click();
        
        return true;
	};
    
     isEmail=function(string) {
		if (string.search(/^\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			return true;
		else return false;
    };
    close_popup=function(){		
		var fel=$('#f_focus').html();
        $('#backoverlay').hide();
		$('#show_popup').hide();
		$('#' + fel ).focus();
	};
    
    });

</script> 